# -*- coding: utf-8 -*-
import os
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'TuringClass.settings')
import django
from app_TuringClass.models import *
from app_accounts.models import *
from app_OnlineExam.models import *
from django.contrib.auth.models import User
import datetime
## author：houchaoqun
## function：初始化用户数据库
## date：2016/11/10

def Population():
	AddCourse("001", "高等数学")
	AddCourse("002", "高等代数")
	AddCourse("003", "C/C++")
	AddCourse("004", "英语")
	AddCourse("005", "思政课")
	AddCourse("006", "问卷调查")


def AddCourse(CourseID, CourseName):
	print "[CourseID] = ",CourseID
	if Course.objects.filter(CourseID = CourseID).exists():
		print "[Course has been existed...]",CourseName
	else:
		NewCourse = Course.objects.get_or_create(CourseID = CourseID, CourseName = CourseName)[0]
		NewCourse.save()
		print "-- function [AddCourse] successful... "


### main program
if __name__ == '__main__':
	print 'DB_OnlineExam_init.py - running...'
	Population()
